using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;

namespace LyonMag
{
    public partial class Forumarticle : PhoneApplicationPage
    {

        string id = string.Empty;
        private App app = App.Current as App;
        List<Cinema.ForumComments> obj = new List<Cinema.ForumComments>();
        string title = string.Empty;
        string header = string.Empty;
        string imageurl = string.Empty;
        string category = string.Empty;
        string date = string.Empty;
        string commentscount = string.Empty;
      
        string thumbtitle = string.Empty;
        public Forumarticle()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {

                //NavigationContext.QueryString.TryGetValue("title", out title).ToString();
                //NavigationContext.QueryString.TryGetValue("header", out header).ToString();
                //NavigationContext.QueryString.TryGetValue("imageurl", out imageurl).ToString();
                //NavigationContext.QueryString.TryGetValue("category", out category).ToString();
                //NavigationContext.QueryString.TryGetValue("date", out date).ToString();
                //NavigationContext.QueryString.TryGetValue("commentscount", out commentscount).ToString();
                NavigationContext.QueryString.TryGetValue("id", out id).ToString();
                //NavigationContext.QueryString.TryGetValue("thumb", out thumbtitle).ToString();
                //// web.NavigateToString(header);
                //System.Windows.Media.Imaging.BitmapImage nit = new System.Windows.Media.Imaging.BitmapImage();
                //nit.UriSource = new Uri(imageurl);
                //img.Source = nit;
                for (int i = 0; i < app.lst_Forum.Count(); i++)
                {
                    if (app.lst_Forum[i].Id == id)
                    {
                        txtTile.Text = app.lst_Forum[i].Category;
                       
                        txtDescription.Text = app.lst_Forum[i].Header; 
                        txtHeader.Text = app.lst_Forum[i].Title; 
                      
                        txtThumbTitle.Text = app.lst_Forum[i].Thumbtitle;
                        System.Windows.Media.Imaging.BitmapImage nit = new System.Windows.Media.Imaging.BitmapImage();
                        nit.UriSource = new Uri(app.lst_Forum[i].AppImage);
                        img.Source = nit;
                        DateTime MyDateTime;
                        MyDateTime = new DateTime();
                        MyDateTime = Convert.ToDateTime(app.lst_Forum[i].Fulldate.ToString());
                        string inputFormat = "dd-MM-yyyy HH:mm:ss";
                      //  txtDate.Text = MyDateTime.ToString(inputFormat);
                        txtDate.Text = MyDateTime.ToString(inputFormat); 
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }

        private void stkTwitter_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            try
            {
                ShareLinkTask obj_share = new ShareLinkTask();
                obj_share.Message = title;
                obj_share.Title = title;
                obj_share.LinkUri = new Uri("http://www.lyonmag.com");
                obj_share.Show();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }

        private void stkEmail_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            try
            {
                ShareLinkTask obj_share = new ShareLinkTask();
                obj_share.Message = title;
                obj_share.Title = title;
                obj_share.LinkUri = new Uri("http://www.lyonmag.com");
                obj_share.Show();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }

        private void stkFacebook_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            try
            {
                ShareLinkTask obj_share = new ShareLinkTask();
                obj_share.Message = title;
                obj_share.Title = title;
                obj_share.LinkUri = new Uri("http://www.lyonmag.com");
                obj_share.Show();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }

        private void stkComments_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/comments.xaml?id=" + id, UriKind.RelativeOrAbsolute));
        }
    }
}